/ Assembly List / LJCBackupChangesLib / BackupChanges / Run

Namespace - LJCBackupChangesLib


Parameters
targetRoot - The Target root path.

Syntax

C#
public Void Run(String targetRoot)

Applies the change commands.

Remarks

The Run() method copies files to, or deletes files from, the target root folder and subfolders using a filespec based on the targetRoot, each source "Changes" filespec and the startFolder value.

For Example:
targetRoot = "C:\Visual Studio 2022\LJCProjects"
sourceSpec = "C:\Visual Studio 2022\LJCProjectsDev\CoreUtilities\LJCBackupChanges\LJCBackupChanges.sln"
startFolder = "LJCProjectsDev";
The targetRoot is combined with the remainder of the sourceSpec starting after the startFolder.
targetSpec = "C:\Visual Studio 2022\LJCProjects\CoreUtilities\LJCBackupChanges\LJCBackupChanges.sln"

Target and source paths that do not match can be handled with the startFolder entry.

The Run() method takes the targetRoot parameter. The startFolder and changesFilespec are initialized in the BackupChanges constructor.

targetRoot - The full path to the target files root folder. The files in this folder and all subfolders are the target of the backup.

changesFileSpec - The full file specification for the "Changes" file.

startFolder - The targetFilespec is created by using the targetRoot combined with the remainder of the sourceSpec starting after the startFolder.

Target and source paths that do not match can be handled with the startFolder entry.

Example 1: targetRoot is shorter than sourceSpec:
targetRoot = "C:\LJCProjects"
sourceSpec = "C:\Visual Studio 2022\LJCProjectsDev\CoreUtilities\LJCBackupChanges\LJCBackupChanges.sln"
startFolder = "LJCProjectsDev"
targetSpec = "C:\LJCProjects\CoreUtilities\LJCBackupChanges\LJCBackupChanges.sln"

Example 2: targetRoot is longer than sourceSpec:
targetRoot = "C:\Visual Studio 2022\LJCProjects"
sourceSpec = "C:\LJCProjectsDev\CoreUtilities\LJCBackupChanges\LJCBackupChanges.sln"
startFolder = "LJCProjectsDev"
targetSpec = "C:\Visual Studio 2022\LJCProjects\CoreUtilities\LJCBackupChanges\LJCBackupChanges.sln"

Example

C#
using LJCCreateFileChangesLib;
using LJCBackupChangesLib;

// Create parameter values.
var sourceRoot = "C:\Visual Studio 2022\LJCProjectsDev";
var targetRoot = "C:\Visual Studio 2022\LJCProjects";
var changesFilespec = "C:\Visual Studio 2022\LJCProjectsDev\ChangesFile.txt";
var includeFilter = "*.cs|*.sln|*.csproj|*.Designer.cs|*.resx|*.config";
includeFilter += "|*.cmd|*.txt|*.sql|Doc\*.xml";
var skipFiles="?Build*.cmd|ClearBuild.cmd|UpdateAll.cmd|Build.txt";
skipFiles += "|ChangesFile.txt|BackupLog.txt|MissingFolders.txt";

// Create the "Changes" file.
var createFileChanges = new CreateFileChanges(sourceRoot, targetRoot
, changesFileSpec, includeFilter);
var skipList = skipFiles.Split('|').ToList<string>();
createFileChanges.SkipFiles = skipList;
createFileChanges.Run();
        
// Create parameter values.
var startFolder = "LJCProjectsDev";

// Backup from LJCProjectsDev to LJCProjects.
var backupChanges = new BackupChanges(startFolder, changesFilespec);
backupChanges.Run(targetRoot);

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.